//
//  DiscoverClassifyCollectionViewCellFirst.m
//  XYFMApp
//
//  Created by 岁变 on 16/9/6.
//  Copyright © 2016年 岁变. All rights reserved.
//

#import "DiscoverClassifyCollectionViewCellFirst.h"
#import "XYMacro.h"

@implementation DiscoverClassifyCollectionViewCellFirst

- (instancetype)initWithFrame:(CGRect)frame {
    
    self = [super initWithFrame:frame];
    if (self) {
        _tableView = [[BaseTableView alloc] initWithFrame:self.contentView.bounds style:UITableViewStylePlain];
        _tableView.delegate = self;
        _tableView.dataSource = self;
        _tableView.showsVerticalScrollIndicator = NO;
        [self.contentView addSubview:_tableView];
        [_tableView registerClass:[DiscoverClassifyTableViewCellFirst class] forCellReuseIdentifier:@"DiscoverClassifyTableViewCellFirst"];
        [_tableView registerClass:[DiscoverClassifyTableViewCellSecond class] forCellReuseIdentifier:@"DiscoverClassifyTableViewCellSecond"];
    }
    return self;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    
    return 3;
    
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    if (indexPath.row == 0) {
        DiscoverClassifyTableViewCellFirst *cell = [tableView dequeueReusableCellWithIdentifier:@"DiscoverClassifyTableViewCellFirst"];
        cell.modelArr = _model.top_items;
        return cell;
    } if (indexPath.row == 1) {
        DiscoverClassifyTableViewCellSecond *cell = [tableView dequeueReusableCellWithIdentifier:@"DiscoverClassifyTableViewCellSecond" forIndexPath:indexPath];
        cell.modelArr = _model.top_musics;
        cell.count = 1;
        return cell;
    } else {
        DiscoverClassifyTableViewCellSecond *cell = [tableView dequeueReusableCellWithIdentifier:@"DiscoverClassifyTableViewCellSecond" forIndexPath:indexPath];
        cell.modelArr = _model.newest_music;
        cell.count = 2;
        return cell;
    }
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    if (indexPath.row == 0) {
        return 360;
    } else {
        return 330;
    }
}


- (void)setModel:(ClassifyModelFirstData *)model {
    _model = [[ClassifyModelFirstData alloc] init];
    _model = model;
    [self.tableView reloadData];
}





@end
